<template>
  <h1>图书ID-基于params传参：{{ $route.params.id }}</h1>
  <h1>图书ID-基于query传参：{{ $route.query.id }}</h1>
  <h1>图书ID-基于封装的方法：{{ getParameter("id") }}</h1>
</template>

<script>
export default {
  name: "BookDetails",
  created() {
    console.log(this.getParameter("id"));
  },
  methods:{
     getParameter(filed){
        return this.$route.params[filed] || this.$route.query[filed];
     }
  }
}
</script>

<style scoped>

</style>